# -*- coding: utf-8 -*-
# @Time    : 2024/8/30 14:39
# @Author  : qd
# @Email   : 1518603573@qq.com
# @File    : fiance_yfk_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.common.alert import Alert
class YfkPage(BasePage):
    url="/crm/index.php?m=finance&a=index&t=payables"
    """添加应付款按钮定位器"""
    yfk_btn_add_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(1) > div.pull-right > a:nth-child(1)")
    """要删除的一条应付款定位器"""
    yfk_select_locator = (By.CSS_SELECTOR, "#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input")
    """应付款删除按钮定位器"""
    yfk_btn_delete_locator = (By.ID, "delete")
    """搜索应付款关键字输入框定位器"""
    yfk_input_search_locator = (By.ID, "search")
    """应付款搜索按钮"""
    yfk_btn_search_locator = (By.CSS_SELECTOR, "#searchForm > ul > li:nth-child(4) > button")
    """"""
    yfk_get_after_search_text_locator=(By.CSS_SELECTOR,"#form1 > table > tbody > tr > td:nth-child(2) > a")

    """点击添加应付款按钮"""
    def click_yfk_add_btn(self):
        self.driver.find_element(*self.yfk_btn_add_locator).click()

    """输入关键字搜索"""
    def input_yfk_search(self,yfk_keywords):
        self.driver.find_element(*self.yfk_input_search_locator).send_keys(yfk_keywords)

    """输入关键字搜索"""
    def click_yfk_search_btn(self):
        self.driver.find_element(*self.yfk_btn_search_locator).click()

    """选中要删除的应付款"""
    def click_yfk_select(self):
        self.driver.find_element(*self.yfk_select_locator).click()
    """点击删除"""
    def click_yfk_btn_delete(self):
        self.driver.find_element(*self.yfk_btn_delete_locator).click()
    """确定警告框"""
    def click_yfk_alert(self):
        self.driver.switch_to.alert.accept()
    """搜索之后的文本"""
    def get_after_search_text(self):
        return self.driver.find_element(*self.yfk_get_after_search_text_locator).text.strip()
